home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / Narzedzia systemowe / Inno Setup 5.0.4 Beta / isetup-5.0.4-beta.exe / {app} / Examples / CodeExample1.iss (.txt) < prev    next >
Encoding:
Inno Setup Script  |  2004-08-02  |  4.7 KB  |  96 lines

  1. ; -- CodeExample1.iss --
  2. ; This script shows various things you can achieve using a [Code] section
  3. [Setup]
  4. AppName=My Program
  5. AppVerName=My Program version 1.5
  6. DefaultDirName={code:MyConst}\My Program
  7. DefaultGroupName=My Program
  8. UninstallDisplayIcon={app}\MyProg.exe
  9. InfoBeforeFile=Readme.txt
  10. [Files]
  11. Source: "MyProg.exe"; DestDir: "{app}"; Check: MyProgCheck; BeforeInstall: BeforeMyProgInstall('MyProg.exe'); AfterInstall: AfterMyProgInstall('MyProg.exe')
  12. Source: "MyProg.hlp"; DestDir: "{app}"; Check: MyProgCheck; BeforeInstall: BeforeMyProgInstall('MyProg.hlp'); AfterInstall: AfterMyProgInstall('MyProg.hlp')
  13. Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
  14. [Icons]
  15. Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
  16. [Code]
  17.   MyProgChecked: Boolean;
  18.   MyProgCheckResult: Boolean;
  19.   FinishedInstall: Boolean;
  20. function InitializeSetup(): Boolean;
  21. begin
  22.   Result := MsgBox('InitializeSetup:' #13#13 'Setup is initializing. Do you really want to start setup?', mbConfirmation, MB_YESNO) = idYes;
  23.   if Result = False then
  24.     MsgBox('InitializeSetup:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
  25. procedure DeinitializeSetup();
  26.   FileName: String;
  27.   ResultCode: Integer;
  28. begin
  29.   if FinishedInstall then begin
  30.     if MsgBox('DeinitializeSetup:' #13#13 'The [Code] scripting demo has finished. Do you want to uninstall My Program now?', mbConfirmation, MB_YESNO) = idYes then begin
  31.       FileName := ExpandConstant('{uninstallexe}');
  32.       if not Exec(FileName, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode) then
  33.         MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
  34.     end else
  35.       MsgBox('DeinitializeSetup:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
  36.   end;
  37. procedure CurStepChanged(CurStep: TSetupStep);
  38. begin
  39.   if CurStep = ssPostInstall then
  40.     FinishedInstall := True;
  41. function NextButtonClick(CurPageID: Integer): Boolean;
  42.   ResultCode: Integer;
  43. begin
  44.   case CurPageID of
  45.     wpSelectDir:
  46.       MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardDirValue + '''.', mbInformation, MB_OK);
  47.     wpSelectProgramGroup:
  48.       MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardGroupValue + '''.', mbInformation, MB_OK);
  49.     wpReady:
  50.       begin
  51.         if MsgBox('NextButtonClick:' #13#13 'Using the script, files can now be extracted before the installation starts. For example we could extract ''MyProg.exe'' now and run it.' #13#13 'Do you want to do this?', mbConfirmation, MB_YESNO) = idYes then begin
  52.           if ExtractTemporaryFile('myprog.exe') then begin
  53.             if not Exec(ExpandConstant('{tmp}\myprog.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
  54.               MsgBox('NextButtonClick:' #13#13 'The file could not be executed. ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
  55.           end else
  56.             MsgBox('NextButtonClick:' #13#13 'The file could not be extracted.', mbError, MB_OK);
  57.         end;
  58.         BringToFrontAndRestore();
  59.         MsgBox('NextButtonClick:' #13#13 'The normal installation will now start.', mbInformation, MB_OK);
  60.       end;
  61.   end;
  62.   Result := True;
  63. function ShouldSkipPage(PageID: Integer): Boolean;
  64. begin
  65.   { Skip wpInfoBefore page; show all others }
  66.   case PageID of
  67.     wpInfoBefore:
  68.       Result := True;
  69.   else
  70.     Result := False;
  71.   end;
  72. procedure CurPageChanged(CurPageID: Integer);
  73. begin
  74.   case CurPageID of
  75.     wpWelcome:
  76.       MsgBox('CurPageChanged:' #13#13 'Welcome to the [Code] scripting demo. This demo will show you some possibilities of the scripting support.' #13#13 'The scripting engine used is RemObjects Pascal Script by Carlo Kok. See http://www.remobjects.com/?ps for more information.', mbInformation, MB_OK);
  77.     wpFinished:
  78.       MsgBox('CurPageChanged:' #13#13 'Welcome to final page of this demo. Click Finish to exit.', mbInformation, MB_OK);
  79.   end;
  80. function MyProgCheck(): Boolean;
  81. begin
  82.   if not MyProgChecked then begin
  83.     MyProgCheckResult := MsgBox('MyProg:' #13#13 'Do you want to install MyProg.exe and MyProg.hlp to ' + ExtractFilePath(CurrentFileName) + '?', mbConfirmation, MB_YESNO) = idYes;
  84.     MyProgChecked := True;
  85.   end;
  86.   Result := MyProgCheckResult;
  87. procedure BeforeMyProgInstall(S: String);
  88. begin
  89.   MsgBox('BeforeMyProgInstall:' #13#13 'Setup is now going to install ' + S + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
  90. procedure AfterMyProgInstall(S: String);
  91. begin
  92.   MsgBox('AfterMyProgInstall:' #13#13 'Setup just installed ' + S + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
  93. function MyConst(Param: String): String;
  94. begin
  95.   Result := ExpandConstant('{pf}');
  96.